package com.graduation.roombooking.config;


import com.graduation.roombooking.mapper.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Author:CaiShuangLian
 * @FileName:
 * @Date:Created in  2022/4/23 14:42
 * @Version:
 * @Description:定时任务
 */
@Configuration
@EnableScheduling//开启定时任务
public class StaticScheduleTask {

    @Autowired
    private OrderMapper orderMapper;
//    @Autowired
//    private CustomTaskScheduler customTaskScheduler;

    @Scheduled(cron = "0 0 1 * * ?")
//    @Scheduled(fixedRate = 5000)
    @Transactional(rollbackFor = Exception.class)//开启事务
    public Integer scheduleTask(){
        System.out.println("进入定时任务");
        int row=0;
        try {
           row= orderMapper.scheduleTask();
        }catch (Exception e){
            e.printStackTrace();
        }
//        boolean flag=
        return row;
    }
}
